package com.example.mc.modules.mc.service.impl;

import com.example.common.msg.dto.MemberLogDTO;
import com.example.mc.modules.mc.entity.MemberLog;
import com.example.mc.modules.mc.mapper.MemberLogMapper;
import com.example.mc.modules.mc.service.IMemberLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 日志表 服务实现类
 * </p>
 *
 * @author 章侠杰
 * @since 2019-01-02
 */
@Service
public class MemberLogServiceImpl extends ServiceImpl<MemberLogMapper, MemberLog> implements IMemberLogService {

    @Override
    public boolean insertLog(MemberLogDTO data) {
        MemberLog log = new MemberLog();
//        log.setType();
        log.setTitle(data.getTitle());
        log.setServiceId(data.getServiceId());
        log.setRemoteAddr(data.getRemoteAddr());
        log.setUserAgent(data.getUserAgent());
        log.setRequestUri(data.getRequestUri());
        log.setMethod(data.getMethod());
        log.setParams(data.getParams());
        log.setTime(data.getTime().toString());
        log.setException(data.getException());
        log.setCreateDate(LocalDateTime.now());
        log.setCreateBy(data.getCreateBy());
        return save(log);
    }
}
